API Documentation
Public Member Functions | List of all members
nkGraphics::Mesh Class Referenceabstract

Holds information about a mesh. Used as a basis to render 3d models. More...

Inheritance diagram for nkGraphics::Mesh:
nkGraphics::Resource nkExport::Exportable

Public Member Functions

 Mesh ()
 
virtual ~Mesh ()
 
void resetCpuBuffers ()
 
bool fillPackedFromUnpacked ()
 
void computeBounds ()
 
virtual int getVertexBufferCount () const
 
virtual unsigned int getVertexCount () const
 
virtual unsigned int getIndexCount () const
 
unsigned int getId () const
 
bool getPackedBufferReady () const
 
bool getAutoComputeBounds () const
 
BoundingBoxgetBounds () const
 
void setVertexCount (int value)
 
void setIndexCount (int value)
 
void setId (unsigned int value)
 
void setPackedBufferReady (bool value)
 
void setAutoComputeBounds (bool value)
 
VertexComposition::VertexComponent * getCurrentVertexArray () const
 
VertexComposition::VertexComponent * getNewVertexArray (unsigned int requestedPointNumber)
 
float * getCurrentVertexPackedArray () const
 
float * getNewVertexPackedArray (unsigned int requestedPointNumber)
 
unsigned int * getCurrentIndexArray () const
 
unsigned int * getNewIndexArray (unsigned int requestedIndexNumber)
 
void setVertexComposition (const VertexComposition &compo)
 
VertexCompositiongetCurrentVertexComposition ()
 
virtual void prepareForGeometryStream ()=0
 
virtual void freeShadowBuffers (bool cleanUnpacked, bool cleanPacked)
 
void generateTangent ()
 
void generateBinormal ()
 
virtual void exportClassToTree (nkExport::Node *rootNode) override
 
virtual void importClassFromTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkGraphics::Resource
 Resource ()
 
 Resource (const char *path)
 
virtual ~Resource ()
 
virtual bool load ()=0
 
virtual void unload ()=0
 
bool isReadyForRendering () const
 
bool isUnloaded () const
 
RESOURCE_LOAD_STATE getLoadState () const
 
std::string_view getResourcePath () const
 
RESOURCE_TYPE getResourceTypeName () const
 
std::string_view getResourceName () const
 
bool getHidden () const
 
virtual void setResourcePath (const std::string_view &path)
 
void setResourceName (const std::string_view &name)
 
void setHidden (bool value)
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable ()
 
virtual ~Exportable ()
 

Detailed Description

Holds information about a mesh. Used as a basis to render 3d models.

See MeshManager::createOrRetrieve() to allocate new instances. This API will evolve and be redesigned soon. It is advised to reduce the number of calls made.

Constructor & Destructor Documentation

◆ Mesh()

nkGraphics::Mesh::Mesh ( )

Constructor. See MeshManager::

◆ ~Mesh()

virtual nkGraphics::Mesh::~Mesh ( )
virtual

Destructor.

Member Function Documentation

◆ resetCpuBuffers()

void nkGraphics::Mesh::resetCpuBuffers ( )

Resets the cpu buffers and free the memory allocated.
Can be used after the mesh is fully loaded to free CPU memory.

◆ fillPackedFromUnpacked()

bool nkGraphics::Mesh::fillPackedFromUnpacked ( )

Fills the packed buffers from the unpacked buffers. This is done automatically when loading.

Returns
If the filling went well (true) or not (false).

◆ computeBounds()

void nkGraphics::Mesh::computeBounds ( )

Computes the bounds of the mesh. Done during loading, if the auto generation is enabled.

◆ getVertexBufferCount()

virtual int nkGraphics::Mesh::getVertexBufferCount ( ) const
virtual
Returns
The vertex buffer count. Currently, only one buffer is used for a mesh.

◆ getVertexCount()

virtual unsigned int nkGraphics::Mesh::getVertexCount ( ) const
virtual
Returns
The number of vertices.

◆ getIndexCount()

virtual unsigned int nkGraphics::Mesh::getIndexCount ( ) const
virtual
Returns
The number of indices.

◆ getId()

unsigned int nkGraphics::Mesh::getId ( ) const
Returns
The id of the mesh.

◆ getPackedBufferReady()

bool nkGraphics::Mesh::getPackedBufferReady ( ) const
Returns
Whether the packed CPU buffer is ready (true) or not (false).

◆ getAutoComputeBounds()

bool nkGraphics::Mesh::getAutoComputeBounds ( ) const
Returns
Whether the mesh auto-computes its bounds (true) or not (false).

◆ getBounds()

BoundingBox* nkGraphics::Mesh::getBounds ( ) const
Returns
The bounds of the meshes.

◆ setVertexCount()

void nkGraphics::Mesh::setVertexCount ( int  value)

Sets the number of vertices of the mesh.

Parameters
valueThe number of vertices to use.

◆ setIndexCount()

void nkGraphics::Mesh::setIndexCount ( int  value)

Sets the number of indices of the mesh.

Parameters
valueThe number of indices to use.

◆ setId()

void nkGraphics::Mesh::setId ( unsigned int  value)

Sets the id of the mesh. Used internally for tracking.

Parameters
valueThe id to use.

◆ setPackedBufferReady()

void nkGraphics::Mesh::setPackedBufferReady ( bool  value)

Sets whether the packed buffer is ready to use.
Can be used to fill directly the packed buffer and avoid the packing step.

Parameters
valueIf the packed buffer is ready (true) or not (false).

◆ setAutoComputeBounds()

void nkGraphics::Mesh::setAutoComputeBounds ( bool  value)

Sets whether the loading step should compute the bounds of the mesh.

Parameters
valueIf the bounds should be computed (true) or not (false).

◆ getCurrentVertexArray()

VertexComposition::VertexComponent* nkGraphics::Mesh::getCurrentVertexArray ( ) const
Returns
Currently allocated vertex array, unpacked.

◆ getNewVertexArray()

VertexComposition::VertexComponent* nkGraphics::Mesh::getNewVertexArray ( unsigned int  requestedPointNumber)

Creates a new unpacked vertex array of requested size, and returns it for populating.

Parameters
requestedPointNumberThe number of vertices the array should feature.
Remarks
The mesh is responsible for memory returned. External code should never delete it. See freeShadowBuffers().

◆ getCurrentVertexPackedArray()

float* nkGraphics::Mesh::getCurrentVertexPackedArray ( ) const
Returns
Currently allocated vertex array, packed.

◆ getNewVertexPackedArray()

float* nkGraphics::Mesh::getNewVertexPackedArray ( unsigned int  requestedPointNumber)

Creates a new packed vertex array of requested size, and returns it for populating.

Parameters
requestedPointNumberThe number of vertices the array should feature. Final size will be computed according to the composition, be sure it is updated.
Remarks
The mesh is responsible for memory returned. External code should never delete it. See freeShadowBuffers().

◆ getCurrentIndexArray()

unsigned int* nkGraphics::Mesh::getCurrentIndexArray ( ) const
Returns
Currently allocated index array.

◆ getNewIndexArray()

unsigned int* nkGraphics::Mesh::getNewIndexArray ( unsigned int  requestedIndexNumber)

Creates a new index array of requested size, and returns it for populating.

Parameters
requestedIndexNumberThe number of vertices the array should feature.
Remarks
The mesh is responsible for memory returned. External code should never delete it. See freeShadowBuffers().

◆ setVertexComposition()

void nkGraphics::Mesh::setVertexComposition ( const VertexComposition compo)

Sets the vertex composition to use.

Parameters
compoThe composition to use.

◆ getCurrentVertexComposition()

VertexComposition& nkGraphics::Mesh::getCurrentVertexComposition ( )
Returns
The currently used vertex composition.

◆ prepareForGeometryStream()

virtual void nkGraphics::Mesh::prepareForGeometryStream ( )
pure virtual

Allows the mesh to be used as an output for a geometry stream.

◆ freeShadowBuffers()

virtual void nkGraphics::Mesh::freeShadowBuffers ( bool  cleanUnpacked,
bool  cleanPacked 
)
virtual

Frees the shadow buffers, aka the CPU buffers.
Can be called after loading the mesh to free requested memory.

Parameters
cleanUnpackedIf the unpacked buffer should be cleaned.
cleanPackedIf the packed buffer should be cleaned.

◆ generateTangent()

void nkGraphics::Mesh::generateTangent ( )

Utility for generating the tangents out of available information in the cpu buffer.

◆ generateBinormal()

void nkGraphics::Mesh::generateBinormal ( )

Utility for generating the binormals out of available information in the cpu buffer.

◆ exportClassToTree()

virtual void nkGraphics::Mesh::exportClassToTree ( nkExport::Node rootNode)
overridevirtual

Basic exporting capabilities.

Parameters
rootNodeThe tree to export to.

Implements nkExport::Exportable.

◆ importClassFromTree()

virtual void nkGraphics::Mesh::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

Basic importing capabilities.

Parameters
rootNodeThe tree to import from.

Implements nkExport::Exportable.


The documentation for this class was generated from the following file: